<template>
	<uni-popup ref="popup" type="dialog">
		<view class="images-container">
			<view class="image-list">
				<image v-for="img in bossImages" :key="img" class="boss-image" :src="img" mode="aspectFit" @click="imageClick(img)"></image>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	import bossImages from './boss-images.js'
	export default {
		name: "image-selector",
		emits: ['select'],
		data() {
			return {
				bossImages
			};
		},
		methods: {
			imageClick(img) {
				this.$emit('select', img);
				this.close();
			},
			open() {
				this.$refs.popup.open();
			},
			close() {
				this.$refs.popup.close();
			}
		}
	}
</script>

<style>
	.images-container {
		padding: 20px;
		width: 80vw;
		background-color: #fff;
		border-radius: 8px;
	}

	.image-list {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.image-buttons {
		display: flex;
		justify-content: space-between;
		margin-top: 20px;
	}

	.cancel-btn {
		flex: 1;
		margin-right: 10px;
	}

	.confirm-btn {
		flex: 1;
		background-color: #007aff;
		color: white;
	}

	.boss-image {
		width: 50px;
		height: 50px;
		border-radius: 4px;
		object-fit: contain;
		padding: 0 5;
	}

	.image-list .boss-image {
		margin: 3px;
	}
</style>